#include "fileops.h"
int is_valid_dir(const char *path){
    struct stat st;
    if(stat(path,&st)==0 && S_ISDIR(st.st_mode)){

    }else{
        return -1;
    }
    if(access(path,F_OK)==0){
        return 0;
    }else{
        return -2;
    }
}
int is_base(char*base,const char *path){
 size_t base_len = strlen(path);
    if (strncmp(base, path, base_len) != 0) {
        return -1;  // 前缀不匹配
    }

    // 确保 path 的下一个字符是 '/' 或结束符
    if (path[base_len] == '/' || path[base_len] == '\0') {
        return 1;  // 是合法子路径
    }

    return -1;  // 类似 /home/user2，这种误匹配要排除
}
int build_full_path(const char*cwd,const char*input_path,char*full_path){
    if(input_path[0]=='/'){
       return -1;
    }else{
        snprintf(full_path,100,"%s/%s",cwd,input_path);
        return 0;
    }
}
